//
//  UIViewController+VIMP.m
//  practice
//
//  Created by Jim on 2017/3/3.
//  Copyright © 2017年 Jim. All rights reserved.
//

#import "UIViewController+VIMP.h"
#import <objc/runtime.h>

typedef void (*_VIMP)(id, SEL, ...);

@implementation UIViewController (VIMP)

+ (void)load
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Method viewDidLoad = class_getInstanceMethod(self, @selector(viewDidLoad));
        _VIMP viewDidLoad_VIMP = (_VIMP)class_getMethodImplementation(self, @selector(viewDidLoad));
        method_setImplementation(viewDidLoad, imp_implementationWithBlock(^(id target, SEL action) {
            NSLog(@"\n控制器%@已加载\n", target);
            viewDidLoad_VIMP(target, action);
        }));
    });
}

@end
